package com.zbkj.service.model.dto.order;

import com.zbkj.dal.entity.order.OrderRentPaymentRecord;
import com.zbkj.dal.entity.order.OrderRentSharedRecord;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.time.LocalDateTime;

@Data
public class OrderRentRecordCreateDTO {

    @ApiModelProperty("订单号")
    private String orderNo;

    @ApiModelProperty("订单明细ID")
    private Integer orderDetailId;

    @ApiModelProperty("用户id")
    private Integer uid;

    @ApiModelProperty("承享天数")
    private Integer rentDays;

    @ApiModelProperty("承享开始日期")
    private LocalDateTime rentStartDate;

    @ApiModelProperty("类型")
    private OrderRentSharedRecord.RentType type;

    @ApiModelProperty("状态")
    private Integer status;

    public static OrderRentRecordCreateDTO buildRecordWhenOrderCreate(String orderNo, Integer orderDetailId, Integer uid, Integer rentDays) {
        OrderRentRecordCreateDTO orderRentRecordCreateDTO = new OrderRentRecordCreateDTO();
        orderRentRecordCreateDTO.setOrderNo(orderNo);
        orderRentRecordCreateDTO.setOrderDetailId(orderDetailId);
        orderRentRecordCreateDTO.setUid(uid);
        orderRentRecordCreateDTO.setRentDays(rentDays);
        orderRentRecordCreateDTO.setType(OrderRentSharedRecord.RentType.INITIAL);
        orderRentRecordCreateDTO.setStatus(0);
        return orderRentRecordCreateDTO;
    }

    public static OrderRentRecordCreateDTO buildRecordAfterProlongPayment(String orderNo, Integer orderDetailId, Integer uid, Integer rentDays, LocalDateTime payTime) {
        OrderRentRecordCreateDTO orderRentRecordCreateDTO = new OrderRentRecordCreateDTO();
        orderRentRecordCreateDTO.setOrderNo(orderNo);
        orderRentRecordCreateDTO.setOrderDetailId(orderDetailId);
        orderRentRecordCreateDTO.setUid(uid);
        orderRentRecordCreateDTO.setRentDays(rentDays);
        orderRentRecordCreateDTO.setRentStartDate(payTime);
        orderRentRecordCreateDTO.setType(OrderRentSharedRecord.RentType.RENEWAL);
        // 正常承享中
        orderRentRecordCreateDTO.setStatus(1);
        return orderRentRecordCreateDTO;
    }

    public static OrderRentRecordCreateDTO buildRecordAfterProlongPayment(OrderRentPaymentRecord order, OrderRentDTO rentDTO, LocalDateTime payTime) {
        OrderRentRecordCreateDTO orderRentRecordCreateDTO = new OrderRentRecordCreateDTO();
        orderRentRecordCreateDTO.setOrderNo(order.getOrderNo());
        orderRentRecordCreateDTO.setOrderDetailId(rentDTO.getOrderDetailId());
        orderRentRecordCreateDTO.setUid(order.getUid());
        orderRentRecordCreateDTO.setRentDays(rentDTO.getRentDays());
        orderRentRecordCreateDTO.setRentStartDate(payTime);
        orderRentRecordCreateDTO.setType(OrderRentSharedRecord.RentType.RENEWAL);
        // 正常承享中
        orderRentRecordCreateDTO.setStatus(1);
        return orderRentRecordCreateDTO;
    }
}
